package boun.swe.bob.service;

import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * This controller is used for login page actions
 */
public class LoginController extends BaseController {


     /**
     * Shows the page
     *
     * @param httpServletRequest http request
     * @param httpServletResponse http response
     * @return page
     */
    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView showPage(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        Map<String, Object> model = Maps.newHashMap();
        String error = httpServletRequest.getParameter("error");
        String viewMessage = "";
        if(!Strings.isNullOrEmpty(error)) {
            viewMessage = "Wrong username/password...";
        }
        model.put("message", viewMessage);
        return new ModelAndView("login", "model", model);
    }


}
